#####################################################################
# Product:      KnowledgeEngine (Plone Edition)
#
# File:         CheckBox.py
#
# Copyright:    Copyright (c) 2004, Faulkner Technologies
#
# Author:       Tom Cameron
#
# Description:  This file defines the ScorableComponent class/interface,
#               components that are scorable will make use of this
#               abstract class. It hosts some basic methods that can be
#               used or overwritten
#
#####################################################################

#####################################################################
## KnowledgeEngine Library Imports
from Common import *
from ClassInfo import ClassInfo
from PropertyDefinition import *
from PropertyTypes import *
from PropertyFormats import *
from PropertyStructures import *
from ReadableScore import ReadableScoreInfo, ReadableScore

#####################################################################
## Zope Library Imports
# (none)
 
#####################################################################
## Python Library Imports
# (none)


#####################################################################
## ScorableInfo Class Definition
class ScorableInfo(ReadableScoreInfo):
    """
        Defines the class info methods, defining information about
        the class without needing an instance of the class
    """

    #---------------------------------------------------------------#

    def isInstanceOf(self, className):
        """
            Returns if the class is an instance of the specified
            className, or implements the interface specified 
            by the className
        """

        return className == 'Scorable' or ReadableScoreInfo.isInstanceOf(self, className)
    
    #---------------------------------------------------------------#

    def onConfigureProperties(self):
        """
            Automatically called by the Knowledge Engine once
            the class has been loaded.  Use this method to register 
            class specific properties using the PropertyReflection interface.
            
            If this class is sub-classed, a call must be made to
            the super-class to ensure super-class properties are
            correctly registered
            
            NOTE: This method is called before ClassInfo.onAfterStartup()            
        """

        #initialise the super-class properties for reflection
        ReadableScoreInfo.onConfigureProperties(self)

        #add the 'weighting' property        
        self.addPropertyDefinition(PropertyDefinition(identity="weighting", displayName="Weighting", description="The weighting of the score relative to other components", defaultValue=1.0, propertyType=pt_FLOAT, propertyFormat=pf_NATIVE, propertyStructure=ps_ATOMIC))        

        #add the 'showScore' property        
        self.addPropertyDefinition(PropertyDefinition(identity="showScore", displayName="Display Score?", description="Display the score in reports", defaultValue=true, propertyType=pt_BOOLEAN, propertyFormat=pf_SELECTION + pf_YES_NO, propertyStructure=ps_ATOMIC))        

        #add the 'computeScore' property        
        self.addPropertyDefinition(PropertyDefinition(identity="computeScore", displayName="Compute Score", description="Compute the score in reports", defaultValue=true, propertyType=pt_BOOLEAN, propertyFormat=pf_SELECTION + pf_YES_NO, propertyStructure=ps_ATOMIC))        
            
    #---------------------------------------------------------------#

#####################################################################
## Scorable Class Definition
class Scorable(ReadableScore):
    """
        A class to define basic properties and methods of a
        scorable component.
    """

    #---------------------------------------------------------------#

    def __init__(self):
        "Constructor for the object"    
        
        pass

    #---------------------------------------------------------------#
    # defaults
    
    weighting = 1.0 #Default Value
    showScore = true
    computeScore = true

    #---------------------------------------------------------------#

    def getWeighting(self):
        """
            Return weighting of component
        """
        
        return self.weighting

    #---------------------------------------------------------------#      
        
    def isScorable(self):
        """
            If this object is Scorable
        """

        return true
    
    #---------------------------------------------------------------#
        
    def getScore(self, assessment):
        """
            INHERITED: Return the score of the
            component given the specified assessment identity.

            NOTE: Must return a real number
        """

        return None
        
    #---------------------------------------------------------------#
        
    def getMaxScore(self):
        """
            PRIVATE ABSTRACT: Return the maximum possible score

            NOTE: Must return a real number
        """

        return None
        
    #---------------------------------------------------------------#


#####################################################################
## Class Initialisation
# (none)
